package handler.v2;

import java.util.function.Function;

public abstract class FeeCalcHandler {

    protected FeeCalcHandler nextHandler;

    protected Function<Param, Result> function;

    FeeCalcHandler(Function<Param, Result> function){
        this.function = function;
    }

    protected Result handler(Param param, Result result){
        result = calc(param);
        if(nextHandler != null){
            return nextHandler.handler(param, result);
        }
        return result;
    }

    abstract Result calc(Param param);
}
